package com.newbee.app;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.Application;

import com.hhu.newbee.R;
import com.iflytek.cloud.SpeechUtility;

public class SpeechApp extends Application
{

	private static List<Activity> activityList = new ArrayList<Activity>();

	public static final String HEAD_FILE = "/NEWBEE_HEAD";

	public static final String TENCENT_QQ_APPID = "1104769230";

	public static JSONObject userNamePair = new JSONObject();

	@Override
	public void onCreate()
	{

		SpeechUtility.createUtility(SpeechApp.this, "appid="
				+ getString(R.string.app_id));

		super.onCreate();
	}

	@Override
	public void onTerminate()
	{

		super.onTerminate();
	}

	public static void add(Activity activity)
	{
		activityList.add(activity);
	}

	public static void exit()
	{

		for (Activity a : activityList)
		{
			a.finish();
		}
	}

	public static synchronized JSONObject getUserNamePair()
	{
		return userNamePair;
	}

	public static synchronized void setUserNamePair(JSONObject userNamePair)
	{
		SpeechApp.userNamePair = userNamePair;
	}

	public static synchronized void setUserNamePair(String key, String vlaue)
	{
		try
		{
			SpeechApp.userNamePair.put(key, vlaue);
		}
		catch (JSONException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
